package com.main;

import java.awt.*;

/**
 * @Author: Painter
 * @project_name: 五子棋
 * @time: 2022/7/29 20:00
 */


public class Chess {
    public int x = 0;  // x坐标
    public int y = 0;  // y坐标
    public int w = 36;  // 棋子的宽
    public int h = 36;  // 棋子的高
    public int type = 1; // 棋子类型 白棋1  ， 黑棋2

    public boolean last = false;  // 是否是最后一个棋子

    public Chess(int x, int y, int type) {
        this.x = x;
        this.y = y;
        this.type = type;
    }

    public void draw(Graphics g) {
        if (type == 1) {  // 如果棋子的类型等于1（白棋）
            // 绘制白棋
            g.drawImage(ImagesValue.whiteChess, this.x, this.y, this.w, this.h, null);
        } else if (type == 2) {  // 如果棋子的类型等于2（黑棋）
            // 绘制黑棋
            g.drawImage(ImagesValue.blackChess, this.x, this.y, this.w, this.h, null);

        }
        if (last){
            Graphics2D g2d = (Graphics2D) g;
            g2d.setStroke(new BasicStroke(2));
            g2d.setColor(new Color(255, 0, 0));
            g2d.drawRect(this.x+15,this.y+15,6,6);
        }

    }
}
